<extend name="Public/base"/>
<block name="sidebar">
    <include file="sidemenu"/>
</block>
<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>图册</h2>
    </div>
    <form action="{:U('album_save')}" method="post" class="form-horizontal" enctype="multipart/form-data">
        <input type="text" class="hidden" name="id" value="{$data['id']}">
        <div class="form-item">
            <label class="item-label">图册标题</label>
            <div class="controls">
                <input type="text" class="text input-large" name="title" value="{$data['title']}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">图册封面</label>
        <div class="controls">
            <input type="file" id="upload_picture_coverId">
            <input type="hidden" name="coverId" id="cover_id_coverId"/>
            <div class="upload-img-box">
                <notempty name="data['coverId']">
                    <div class="upload-pre-item"><img src="{$data['coverId']|get_cover='path'}"/></div>
                </notempty>
            </div>
        </div>
        <script type="text/javascript">
            //上传图片
            /* 初始化上传插件 */
            $("#upload_picture_coverId").uploadify({
                "height"          : 30,
                "swf"             : "__STATIC__/uploadify/uploadify.swf",
                "fileObjName"     : "download",
                "buttonText"      : "上传图片",
                "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                "width"           : 150,
                'removeTimeout'	  : 1,
                'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                "onUploadSuccess" : uploadPicture_coverId,
            'onFallback' : function() {
                alert('未检测到兼容版本的Flash.');
            }
            });
            function uploadPicture_coverId(file, data){
                var data = $.parseJSON(data);
                var src = '';
                if(data.status){
                    $("#cover_id_coverId").val(data.id);
                    src = data.url || '__ROOT__' + data.path;
                    $("#cover_id_coverId").parent().find('.upload-img-box').html(
                            '<div class="upload-pre-item"><img src="__ROOT__' + src + '"/></div>'
                    );
                } else {
                    updateAlert(data.info);
                    setTimeout(function(){
                        $('#top-alert').find('button').click();
                        $(that).removeClass('disabled').prop('disabled',false);
                    },1500);
                }
            }
        </script>
        </div>

        <!--<div class="form-item">-->
            <!--<label class="item-label">上传图册封面</label>-->
            <!--<div class="controls">-->
                <!--<input type="file" class="text input-large" name="image" value="">-->
                <!--<input type="text" class="hidden" name="url" value="{$data['url']}">-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">封面浏览</label>-->
            <!--<div  class="controls">-->
                <!--<img style="width: 300px; height: 300px;" src="__ROOT__/Uploads{$data['url']}">-->
            <!--</div>-->
        <!--</div>-->
        <div class="form-item">
            <label class="item-label">内容编辑</label>
            <label class="textarea">
                <textarea name="content">{$data['content']}</textarea>
                {:hook('adminArticleEdit', array('name'=>content,'value'=>$data['content']))}
            </label>
        </div>
        <div class="form-item">
            <label class="item-label">是否展示</label>
            <div class="controls">
                <label class="radio"><input type="radio" name="status" value="1" <eq name="data['status']" value="1">checked="checked"</eq>>是</label>
                <label class="radio"><input type="radio" name="status" value="0" <eq name="data['status']" value="0">checked="checked"</eq>>否</label>
            </div>
        </div>
        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>
